package com.ghp.mapper;

import com.ghp.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * UserMapper主要包含与tb_user表相关的SQL方法
 * 主要作用：实现Mapper代理
 * @author ghp
 */
public interface UserMapper {
    /**
     * 判断用户信息是否正确
     * @return null表示密码不正确
     */
    @Select("select * from tb_user where username = #{username} and password = #{password}")
    User select(User user);

    /**
     * 判断用户名是否存在
     * @param username
     */
    @Select("select * from tb_user where username = #{username}")
    User selectByName(@Param("username") String username);

    /**
     * 添加数据
     */
    @Insert("insert into tb_user(username,password) values(#{username},#{password})")
    void add(User user);
}
